package com.hailian.fintech.hlbackingserver.web;


import com.hailian.fintech.hlbackingserver.entity.Bank;
import com.hailian.fintech.hlbackingserver.service.IBankService;
import com.hailian.fintech.hlcomm_interfaceserver.result.ResultInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wk
 * @since 2020-05-30
 */
@RestController
@RequestMapping("/bank")
public class BankController {
    @Autowired
    private IBankService iBankService;

    /**
     * 通过用户id得到银行卡信息
     * @param id
     * @return
     */
    @RequestMapping("getByUid")
    public Object getByid(Integer id){
        List<Bank> banks = iBankService.getByUid(id);
        return new ResultInfo().success(banks);
    }

    /**
     * 添加银行卡
     * @param bank
     * @return
     */
    @RequestMapping("addBank")
    public Object addBank(@RequestBody Bank bank){
        boolean flag  = iBankService.saveOrUpdate(bank);
        return new ResultInfo().success(flag);
    }
    @RequestMapping("delBank")
    public Object delBank(Integer id){
        boolean flag  = iBankService.removeById(id);
        return new ResultInfo().success(flag);
    }




}

